home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 May: Tool Chest / Dev.CD May 98 TC.toast / Tool Chest / Networking / Network Watch (DMZ) v1.5 / sources / OpenTptUtilities.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-25  |  1.3 KB  |  53 lines  |  [TEXT/MMCC]

  1. /*
  2.  
  3.     file: OpenTptUtilities.c
  4.         Set of utility routines for use with Open Transport
  5.  
  6. */
  7.  
  8. /*
  9.     OTExtractNBPCName is useful for extracting the object, type, or zone name
  10.     from an NBPEntity returned from an NBP Lookup call.  The returned string
  11.     is a c style, null delimited string.
  12.     
  13.     Input:
  14.         entity - pointer to the entity string returned from a lookup call
  15.         offset - number of bytes into the entity string where to begin parsing
  16.                     for the desired portion of the nbp.  This call will generally
  17.                     be made three times.  Pass 0 to begin reading from the
  18.                     beginning of the string.  This function returns
  19.                     the number of characters read, including the delimiter character.
  20.                     Use this result as the offset to read the next nbp part.
  21.         delimiter - pointer to character on which to terminate reading.
  22.     
  23.     Output:
  24.         field - pointer to a buffer to recieve the nbp name
  25.         result - number of characters into the buffer where the delimiter
  26.                 or null was read.
  27.         
  28.         
  29.     
  30. */
  31.  
  32. #include <Types.h>
  33. #include <OpenTptAppleTalk.h>
  34. #include "dmz.h"
  35.  
  36. short OTExtractNBPCName(const NBPEntity* entity, char* field, UInt32 offset, UInt8 *delimiter)
  37. {
  38.     char    *p;
  39.     short    numCharsRead = 0;
  40.     
  41.     p = (char*) entity;
  42.     p += offset;
  43.     while ((*p != *delimiter) && (*p != 0))
  44.     {
  45.         *field = *p;
  46.         field++;
  47.         p++;
  48.         numCharsRead++;
  49.     }
  50.     *field = 0;
  51.     numCharsRead++;
  52.     return (numCharsRead);
  53. }